import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { IPage, ICommunity } from "./types";

/* 查询社团列表 */
export function getPageCommunityAPI(
  queryParams?: IPage
): AxiosPromise<PageResult<ICommunity[]>> {
  return request({
    url: "/community/page",
    method: "get",
    params: queryParams,
  });
}
/* 根据id查询社团对象 */
export function getFormCommunityAPI(id: number): AxiosPromise<ICommunity> {
  return request({
    url: `/community/${id}/form`,
    method: "get",
  });
}

/**
 * 添加社团
 *
 * @param data
 */
export function addCommunityAPI(data: any) {
  return request({
    url: "/community",
    method: "post",
    data: data,
  });
}

/**
 * 修改社团
 *
 * @param id
 * @param data
 */
export function updateCommunityAPI(id: number, data: ICommunity) {
  return request({
    url: "/community/" + id,
    method: "put",
    data: data,
  });
}

/**
 * 删除社团
 *
 * @param ids
 */
export function deleteCommunityAPI(ids: number) {
  return request({
    url: "/community/" + ids,
    method: "delete",
  });
}
